<?php

namespace App\Console;

use App\Console\Commands\Corn\CheckWtData;
use App\Console\Commands\Corn\CloseOwner;
use App\Console\Commands\Corn\CreateOwnerItem;
use App\Console\Commands\Corn\GetWtData;
use App\Console\Commands\Corn\SendMessageToAdmin;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

// /home/vagrant/www/house
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        CreateOwnerItem::class,
        CheckWtData::class,
        CloseOwner::class,
        GetWtData::class,
        SendMessageToAdmin::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('corn:close-owner')->hourly();  // 每个小时都执行一次

        // 每个月发送三次短信给管理员
        $schedule->command('corn:send-message-to-admin')->monthlyOn(4, '10:30');
        $schedule->command('corn:send-message-to-admin')->monthlyOn(16, '10:30');
        $schedule->command('corn:send-message-to-admin')->monthlyOn(25, '10:30');

        // 每小时去wt中取一次数据
        $schedule->command('corn:get-wt')->everyThirtyMinutes();
        $schedule->command('corn:check-wt')->hourly();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
